import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/merchant/api/v1/user/login',
    method: 'post',
    data
  })
}

export function getInit() {
  return request({
    url: '/merchant/api/v1/init',
    method: 'get'
  })
}
export function upload(file, param) {
  return request({
    url: '/merchant/api/v1/common/upload',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: file,
    onUploadProgress: progressEvent => {
      const complete = (progressEvent.loaded / progressEvent.total * 100 | 0)
      param.onProgress({ percent: complete })
    }
  })
}
// 修改密码邮箱
export function editInfo(data) {
  return request({
    url: '/merchant/api/v1/user/edit',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    data
  })
}
// 刷新token
export function refreshToken() {
  return request({
    url: '/merchant/api/v1/user/refresh',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
